﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RiskMan.DataClass.Models;
using System.Windows.Threading;
using System.Collections.ObjectModel;
using RiskMan.DataClass.Models.RM;
using RiskMan.Providers.QuikIO;

namespace RiskMan.Views.RMInvestor
{
    public class InvestorsLogic
    {
        private DispatcherTimer _timer = new DispatcherTimer( );
        private ObservableCollection<ModuleInvestorModel> _list;

        public InvestorsLogic ( )
        {
            // интервал
            _timer.Interval = TimeSpan.FromMilliseconds( 1000 );
            _timer.Tick += new EventHandler( Timer_Tick );
            _timer.Start( );
        }

        public void CreateTerminalHandler ( )
        {
        }

        public void Timer_Tick ( Object sender, EventArgs args )
        {
            if ( RiskMan.Views.RMInvestor.RMInvestor.stRMInvestor.CheckConnect( ) == true )
            {
                _list = MainWindow.StaticRiskMan._dataProvider.RmInvestorItems;

                for ( int i = 0; i < _list.Count; i++ )
                {
                    if ( _list [ i ].Run == true )
                    {
                        // расчет логики

                        if ( _list [ i ].Calc( ) == true )
                        {
                            _list [ i ].Updata( );
                            //_list [ i ].CheckLockOrder( );
                        }
                    }
                }
            }
        }
    }
}